package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduComplaint.EduComplaintKeyVO;
import com.jwsoft.manager.common.vo.eduComplaint.EduComplaintQueryVO;
import com.jwsoft.manager.common.vo.eduComplaint.EduComplaintVO;
import com.jwsoft.manager.core.integration.EduComplaintIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 申述管理网关
 *
 * @author wangtao
 * @since 2022-12-02
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "申述管理", description = "申述管理")
public class EduComplaintController {

    @Autowired
    public EduComplaintIntegration eduComplaintIntegration;

    @Operation(summary = "申述管理分页查询",description = "申述管理分页查询")
    @PostMapping(value = "/eduComplaint0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduComplaintVO>> getList(@RequestBody @Validated EduComplaintQueryVO vo) {
        return AppResponse.successData(eduComplaintIntegration.getList(vo));
    }

    @Operation(summary = "申述管理根据主键查询详情",description = "申述管理根据主键查询详情")
    @PostMapping(value = "/eduComplaint0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduComplaintVO> getById(@RequestBody @Validated EduComplaintKeyVO vo) {
        return AppResponse.successData(eduComplaintIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "申述管理新增",description = "申述管理新增")
    @PostMapping(value = "/eduComplaint0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduComplaintVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduComplaintVO vo) {
        return AppResponse.successData(eduComplaintIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "申述管理修改",description = "申述管理修改")
    @PostMapping(value = "/eduComplaint0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduComplaintVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduComplaintVO vo) {
        return AppResponse.successData(eduComplaintIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "申述管理删除",description = "申述管理删除")
    @PostMapping(value = "/eduComplaint0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduComplaintKeyVO vo) {
        eduComplaintIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "处理投诉反馈",description = "处理投诉反馈")
    @PostMapping(value = "/eduComplaint0007", produces = "application/json;charset=UTF-8")
    public AppResponse handleComplainant(@RequestBody @Validated EduComplaintVO vo) {
        eduComplaintIntegration.handleComplainant(vo);
        return AppResponse.success();
    }
}
